var app = getApp();
Page({
    data:{
        siteroot : app.siteInfo.siteroot.replace('app/index.php', ''),uniacid: app.siteInfo.uniacid,
        curPage : "/zofui_sales/comment/list",
        page : {
            isend : false,
            doing : false,
            doo : 'comm',
            pdata : {
                op : 'list',
                page : 1,
                isinit : 1,
                gid : 0,
            },
            waitf : 0,
            nodataf : 0,
        },
        datalist : [],
		
    },
    onLoad:function(options){
        var self = this;
		var gid = options.gid ? options.gid : '';
        var zfid = options.zfid ? options.zfid : '';

        self.setData({
            'page.pdata.isinit' : 1,
            'page.pdata.page' : 1,
            'page.pdata.gid' : gid,
            options : options,
            'page.pdata.zfid' : zfid,
            'page.isend' : false,
            'page.doing' : false,
        });
        app.com.auth(function(user){
            app.com.getPage(self,self.data.page,0,function(res){
                var data = res.data.data;

                self.setData({
                    datalist : data.list,
                    params : data.params,
                    sharedata : data.sharedata,
                    inited : true,
                });
                wx.setNavigationBarTitle({
                    title: '评价',
                });

            },false,function(res){
                app.com.alert(res.data.message,function(){
                    app.com.backPage(0);
                });
            });
        });
        
    },
    onShareAppMessage : function(e){
        var self = this;
        if( e.target.dataset.id ){
            for (var i = 0; i < self.data.datalist.length; i++) {
                if( self.data.datalist[i].commid == e.target.dataset.id ){
                    return {
                        title: self.data.datalist[i].content,
                        path: '/zofui_sales/comment/info?id='+self.data.datalist[i].commid,
                        imageUrl : self.data.datalist[i].thumb,
                    }
                }
            }

        }else{
            return {
                title: self.data.sharedata.title,
                path: self.data.sharedata.path,
                imageUrl : self.data.sharedata.img,
            }
        }
    },
    onPullDownRefresh: function () {
        if( this.data.isdown ) return false;
        this.data.isdown = true;
        this.onLoad( this.data.options );
        this.data.isdown = false;

        wx.stopPullDownRefresh();
    },
    showselect(){
        this.setData({
            showselect : !this.data.showselect
        })
    },
    onReachBottom : function(){
        var self = this;
        app.com.getPage(self,self.data.page,20,function(res){
            self.setData({
                datalist : self.data.datalist.concat(res.data.data.list)
            });
        });
    },
    location : function( e ){
        app.com.location( e );
    },
    otherapp : function( e ){
        app.com.otherapp( e );
    },
    navigateto : function( e ){
        app.com.navigateto( e );
    },
    redirectto : function( e ){
        app.com.redirectto( e );
    },    
    callphone : function(e){
        app.com.callphone( e );
    },
    toweburl : function(e){
        app.com.toweburl( e );
    },
    showimages : function( e ){
        app.com.showimages( e );
    },
    footNavigate(e){
        var url = e.currentTarget.dataset.url;
        wx.switchTab({
          url: url
        })
    },

})